package com.zhao.service.Impl;

import com.github.pagehelper.PageHelper;
import com.zhao.dao.UserMapper;
import com.zhao.pojo.User;
import com.zhao.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;
    //登录
    @Override
    public User selectUserByPWD(User user) {
        return userMapper.selectUserByPWD(user);
    }
    //分页查询全部用户
    @Override
    public List<User> selectAllUser(int page,int limit) {
        PageHelper.startPage(page,limit);
        return userMapper.selectAllUser();
    }
    //增加用户
    @Override
    public int addUser(User user) {
        return userMapper.addUser(user);
    }
    //根据id查询用户
    @Override
    public User selectUserById(int id) {
        return userMapper.selectUserById(id);
    }
    //根据id更新用户
    @Override
    public int updateById(User user) {
        return userMapper.updateById(user);
    }
    //逻辑删除用户
    @Override
    public int deleteUser(int id) {
        return userMapper.deleteUser(id);
    }
}
